<?php
/*
 * Created on 25.01.2006
 * 
 * config:
 * psp-root-dir: dir where public psp are found
 * psp-page:     page to load
 */
 
m2import('phpinchains/Filter.php');
m2import('phpinchains/psp/ViewDispatcher.php');

class ViewDispatcherFilter extends phpinchains_Filter
{
    
    var $config;
    var $initbasedir;
    var $relativeFilePath;

    function doFilter (& $env, & $chain)
    {
        $dispatcher = new ViewDispatcher($this->config['psp-root-dir'], $GLOBALS['MODEL2_NS']);
        if (!empty($this->config['send-actionform'])) {
            print $dispatcher->dispatch($this->config['psp-page'], env::getInstance()->getAttribute('outputtypeActionform'));
        } else {
            print $dispatcher->dispatch($this->config['psp-page']);
        }
        $chain->doFilter($env);
    }
    
    function init (& $config)
    {
        $this->config = & $config;
    }
    
}

?>